// components/activitys/activitys.js
var app = getApp()
Component({
    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
        ArticleList: [{
                article_id: 1,
                title: '登记处志愿站岗',
                state: '已结束',
                originator: '夏清颖',
                end_time: '2020-03-12 16:00:00',
                image: 'https://636c-cloud1-3gwgwntc19418eac-1312065174.tcb.qcloud.la/images/activitys/test.jpeg?sign=445d6f9a0b63609abad55d0b89a9b97d&t=1662034985'
            },
            {
                article_id: 2,
                title: '清理乡村',
                state: '已结束',
                originator: '王志远',
                end_time: '2020-03-12 16:00:00',
                image: 'https://636c-cloud1-3gwgwntc19418eac-1312065174.tcb.qcloud.la/images/activitys/clean.jpeg?sign=90ed9d51b8ecd7d6bda4447d570979e3&t=1662034972'
            },
            {
                article_id: 3,
                title: '辅导功课',
                state: '已结束',
                originator: '李兰华',
                end_time: '2020-03-12 16:00:00',
                image: 'https://636c-cloud1-3gwgwntc19418eac-1312065174.tcb.qcloud.la/images/activitys/teacher.jpeg?sign=356a781d07e3212b98fd26e7cf6fe57c&t=1662035001'
            }
        ]
    },
    
    created() {
        var that = this
        // 登录成功获取所有活动
        wx.cloud.callFunction({
            name: 'volunteer',
            data: {
                type: 'getAllActivity'
            }
        }).then((resp) => {
            console.log('获取的数据', resp.result.data)
            app.globalData.activityList = resp.result.data
            that.setData({
                activityList: resp.result.data
            })
            wx.hideLoading();
        }).catch((e) => {
            console.log('出错了', e);
            wx.hideLoading();
        });
    },
    /**
     * 组件的方法列表
     */
    methods: {
        gotoArticleDetail: function (event) {
            // 当前要跳转到另一个界面，但是会保留现有界面
            wx.navigateTo({
                url: `../eventPageDetails/index?articleid=${event.currentTarget.dataset.articleid}`
            })
        },
    }
})